
package com.rt.schedulenew.utils.util;
public class Encode64BitUtil
{
    static final char[] digits;
    
    public static String CompressNumber(long number) {
        final char[] buf = new char[64];
        int charPos = 64;
        final int radix = 64;
        final long mask = radix - 1;
        do {
            buf[--charPos] = Encode64BitUtil.digits[(int)(number & mask)];
            number >>>= 6;
        } while (number != 0L);
        return new String(buf, charPos, 64 - charPos);
    }
    
    public static long UnCompressNumber(final String decompStr) {
        long result = 0L;
        for (int i = decompStr.length() - 1; i >= 0; --i) {
            for (int j = 0; j < Encode64BitUtil.digits.length; ++j) {
                if (decompStr.charAt(i) == Encode64BitUtil.digits[j]) {
                    result += (long)j << 6 * (decompStr.length() - 1 - i);
                }
            }
        }
        return result;
    }
    
    static {
        digits = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '+', '/' };
    }
}
